 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <title>roles</title>
    <script src="../../plugs/jquery-3.1.1.min.js"></script>
	<script type="text/javascript" src="../../css/layer/layer.js"></script>
    <script src="../../assets/bootstrap/js/bootstrap.min.js"></script>
    <!-- boostrap table  -->
   	<script type="text/javascript" src="../../plugs/jquery-3.1.1.min.js"></script>
	<!-- bootstrap -->
	<link rel="stylesheet" href="../../plugs/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="../../css/layer/mobile/need/layer.css">
	<script type="text/javascript" src="../../plugs/bootstrap/js/bootstrap.min.js"></script>
	<!-- 分页插件 -->
	<link rel="stylesheet" href="../../plugs/bootstrap-table/bootstrap-table.min.css">
	<script type="text/javascript" src="../../plugs/bootstrap-table/bootstrap-table.min.js"></script>
	<script type="text/javascript" src="../../plugs/bootstrap-table/bootstrap-table-locale-all.min.js"></script>
	<!-- 行内编辑 -->
	<script type="text/javascript" src="../../plugs/editable/bootstrap-editable.js"></script>
	<script type="text/javascript" src="../../plugs/editable/bootstrap-table-editable.js"></script>

</head>
<body>
<!--没有查询列表，只有显示作物编码-->
<div class="container" style="margin-top:20px;width: 1200px">
	<div class="row">
		<div id="toolbar">		
        	<button value="待审核" id="unchecked"  class="btn btn-info">待审核</button>
        	<button value="注册" id="allow">注册</button>
		
			<button value="已注册" id="allowed" class="btn btn-info">已注册</button>
			<button value="驳回" id="reject" class="btn btn-danger">驳回</button>
			<button value="已驳回" id="rejected" class="btn btn-danger">已驳回</button>
        	
        	<button value="删除" id="delete">删除</button>
		</div>
		<div class="col-xs-12">
			<table class="table table-striped table-bordered table-hover" ></table>
		</div>
		<p>test</p>
	</div>
</div>
<script src="../../business/js/buttonStyleCover.js"></script>
<script>
$(document).ready(function() 
		{
		init();
		function init(status)
		{
	    	 //---先销毁表格 ---
	        $('table').bootstrapTable('destroy');  
	        //---初始化表格,动态从服务器加载数据--- 
	       //	alert("hello");
			 $('table').bootstrapTable
			 ({
				//发送数据请求
		    	url: '../../system/getPageRegisters.do',
				method: 'post',
				contentType: "application/x-www-form-urlencoded",
				toolbar: '#toolbar',//自定义工具栏
				cache: false,
				height: 600,
				striped: true,
				//search: true,
				//showExport: true,
				//showColumns: true,
				//exportTypes: ['csv','txt','xml'],
				//search: true,
				clickToSelect: true,
				//【查询设置】
				/* queryParamsType的默认值为 'limit' ,在默认情况下 传给服务端的参数为：offset,limit,sort
	                             设置为 ''  在这种情况下传给服务器的参数为：pageSize,pageNumber */
				queryParamsType:'', 
	           	queryParams: function queryParams(params) {
	             var param = {  
	                 pageNumber: params.pageNumber,    
	                 pageSize: params.pageSize,
	                 status:status
	             }; 
	             return param;                   
	           }, 
				//【其它设置】
	           locale:'zh-CN',//中文支持
	           pagination: true,//是否开启分页（*）
	           pageNumber:1,//初始化加载第一页，默认第一页
	           pageSize: 10,//每页的记录行数（*）
	           pageList: [10,15,20],//可供选择的每页的行数（*）
	           sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
	           showRefresh:true,//刷新按钮
	           //【设置列属性】
				columns:
				 [
				 {field:"check",checkbox: true },
				 {field:"id",title:"id"},
				 {field: 'businessName',title:'公司名称'},
				 {field: 'managerNum',title: '账号申请'},	
				 {field: 'managerPwd',title: '账号密码'},	
				 {field: 'managerEmail',title: '用户邮箱'},	
				 {field: 'managerPhone',title: '用户电话'},	
				 {field: 'managerName',title: '姓名'}
				],
	       });
		}
	
				 
		
				
				$('#unchecked').click(function(){
					init("");
				});
				
				$('#allowed').click(function()
				{
					init("1");
				});
				
				$('#rejected').click(function(){
					
					init("0");
				});
				 
				 
				 /* 删除*/
				  $('#delete').click(function(){
						 var rows = $('table').bootstrapTable('getSelections');
						 var rowsNum = rows.length;
						 if(rowsNum == 0)
						 {
							 // alert("未选择数据")
							 layer.msg("未选择数据",{icon: 5})
						 }
						 else
						 {
							 //alert(rows[0].check);
							 //删除第一个check对象，后台不需要，必须处理
							 for(var i =0 ;i< rowsNum ;i++)
								delete rows[i]['check'];
							 $.ajax({
								  type: "post",
								  url: "../../system/deleteRegisterTmpInfo.do",
								  data:{data:JSON.stringify(rows)},
								  //data:	rows,
								  success: function (data, status) {
									  if (status == "success") {
					                        // alert("删除成功");
										  	layer.msg("删除成功",{icon: 1})
					                        //成功之后页面数据删除
					                        $('table').bootstrapTable('refresh');  	
					                    }
					                },
					                error: function () {
					                    // alert("删除失败");
										layer.msg("删除失败",{icon: 5})
					                }
					            });
						  }
					  });		
				 
				 
				 
				 //审核通过
				  $('#allow').click(function(){
						 var rows = $('table').bootstrapTable('getSelections');
						 var rowsNum = rows.length;
						 if(rowsNum == 0)
						 {
							 // alert("未选择数据")
							 layer.msg("未选择数据",{icon: 5})
						 }
						 else
						 {
							 //alert(rows[0].check);
							 //删除第一个check对象，后台不需要，必须处理
							 for(var i =0 ;i< rowsNum ;i++)
								delete rows[i]['check'];
							 $.ajax({
								  type: "post",
								  url: "../../system/allowRegister.do",
								  data:{data:JSON.stringify(rows)},
								  //data:	rows,
								  success: function (data, status) {
									  if (status == "success") {
					                        // alert("审核注册成功");
					                        layer.msg("审核注册成功",{icon: 1})
					                        //成功之后页面数据删除
					                        $('table').bootstrapTable('refresh');  	
					                    }
					                },
					                error: function () {
					                    // alert("注册失败");
										layer.msg("注册失败",{icon: 5})
					                }
					            });
						  }
					  });		
				 
				 
				 
				 
				 //拒绝
				 
				  $('#reject').click(function(){
						 var rows = $('table').bootstrapTable('getSelections');
						 var rowsNum = rows.length;
						 if(rowsNum == 0)
						 {
							 layer.msg("未选择数据",{icon: 5})
						 }
						 else
						 {
							 //alert(rows[0].check);
							 //删除第一个check对象，后台不需要，必须处理
							 for(var i =0 ;i< rowsNum ;i++)
								delete rows[i]['check'];
							 $.ajax({
								  type: "post",
								  url: "../../system/rejectRegister.do",
								  data:{data:JSON.stringify(rows)},
								  //data:	rows,
								  success: function (data, status) {
									  if (status == "success") {
										  layer.msg("操作成功",{icon: 1})
					                        //成功之后页面数据删除
					                        $('table').bootstrapTable('refresh');  	
					                    }
					                },
					                error: function () {
										layer.msg("操作失败",{icon: 5})
					                }
					            });
						  }
					  });		
		  	});
</script>
</body>
</html>